

package net.qiqbframework.commandhandling;

import net.qiqbframework.messaging.MessageHandler;


import javax.annotation.Nonnull;


public class FailingDuplicateCommandHandlerResolver implements DuplicateCommandHandlerResolver {

    private static final FailingDuplicateCommandHandlerResolver INSTANCE = new FailingDuplicateCommandHandlerResolver();


    public static FailingDuplicateCommandHandlerResolver instance() {
        return INSTANCE;
    }

    private FailingDuplicateCommandHandlerResolver() {
    }

    @Override
    public CommandMessageHandler resolve(@Nonnull String commandName,
                                                             @Nonnull CommandMessageHandler registeredHandler,
                                                             @Nonnull CommandMessageHandler candidateHandler) {
        throw new DuplicateCommandHandlerSubscriptionException(commandName, registeredHandler, candidateHandler);
    }
}
